<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
    <title>工作报告</title>
    <link rel="stylesheet" href="../../../css/mui.min.css" />
    <script src="../../../js/mui.min.js"></script>
    <link rel="stylesheet" type="text/css" href="../../../css/app.css" />
    <link rel="stylesheet" href="../../../npl/css/vant.mini.css" />
    <script src="../../../js/jquery-3.6.0.min.js"></script>
    <script src="../../../js/flexible.js"></script>
    <script src="../../../js/vue.js"></script>
    <script src="../../../js/sm2.js"></script>
    <script src="../../../js/sm3.js"></script>
    <script src="../../../js/clipboard.js"></script>
    <script src="../../../npl/js/vant.mini.js"></script>
    <script src="../../../js/vconsole.min.js"></script>
    <script src="../../text.js" type="text/javascript"></script>

    <link rel="stylesheet" href="../css/github-markdown.css" />
    <link rel="stylesheet" href="../css/work.css" />
    <link rel="stylesheet" href="../css/chooseDir.css" />

    <!-- <script src="../js/flexible.js"></script> -->
    <script src="../js/marked.min.js" type="text/javascript"></script>
    <script src="../js/turndown.js" type="text/javascript"></script>
    <script src="../js/util.js" type="text/javascript"></script>
    <script src="../js/stream.js"></script>
    <script src="../js/streamMsg.js"></script>
    <script src="../js/multiBtn.js"></script>
    <script src="../js/chooseDir.js"></script>

</head>

<body class="program-body">
    <div id="app" v-cloak>
        <multi-btn :changeable="changeMultiBtn"></multi-btn>
        <choose-dir ref="chooseDirRef" @choose-dir-upload="chooseDirUpload"></choose-dir>
        <van-image-preview v-model="modelImageShow" :images="modelImages" @change="onImageChange">
            <!-- <template v-slot:index>第{{ modelImageIndex+1 }}页</template> -->
        </van-image-preview>
        <div class="is-loading">
            <div class="curtain">
                <div class="loadingBgc">
                    <div class="loader"></div>
                </div>
            </div>
        </div>
        <div class="trainTickets program-main">
            <div class="header_tit">
                <van-nav-bar title="工作报告" :border=false left-arrow>
                    <template #left>
                        <div class="back_l active-brightness" @click="home()">
                            <img src="../../../image/left.png" alt="" />
                        </div>
                    </template>
                    <template #right>
                        <div class="pre-next">
                            <div class="pre active-brightness" @click="preStep()" v-if="currentStep !=1 && currentStep != 4" >
                                <img src="../images/write/pre-step.png" alt="" />
                            </div>
                            <div class="next active-brightness" @click="nextStep()" v-if="currentStep !=1 && currentStep !=4">
                                <img src="../images/write/next-step.png" alt="" />
                            </div>
                        </div>
                    </template>
                </van-nav-bar>
                <div class="program-titles">
                    <van-row class="step-row">
                        <van-col class="step active-brightness summary-step" span="8" v-for="(item, index) in stepList" :key="item.id">
                            <img v-if="1==item.step" :src="item.acIcon" />
                            <img v-else :src="currentStep >= item.step ? item.acIcon : item.disIcon" />
                        </van-col>
                    </van-row>
                </div>
            </div>
            <!-- 填写表单 -->
            <div v-if="currentStep == 1" class="step1">
                <!-- 主题 -->
                <div class="subject">
                    <div class="field-label">
                        <span class="tit_text">主题</span><span class="first_span_img">*</span>
                    </div>
                    <div class="subject-title">
                        <input id="voiceSubjectTitle" :readonly="1==voiceType" @focus="handleInputFocus" @blur="handleInputBlur" class="subject-input" placeholder="示例：第一季度工作报告" v-model="form.subjectTitle" />
                        <div class="img-div active-brightness" v-if="1!=voiceType" @click="startTalk(1)">
                            <img class="subject-voice" src="../images/write/voice-play.png"/>
                        </div>
                        <div class="img-div active-brightness" v-if="1==voiceType" @click="stopTalk(1)">
                            <img class="subject-voice"  src="../images/write/stop.png" />
                        </div>
                    </div>
                </div>
                <!-- 模板 -->
                <div class="model">
                    <div class="field-label">
                        <span class="tit_text">模板</span><span class="first_span_img">*</span>
                    </div>
                    <div class="m-scroll">
                        <div class="model-list active-brightness" v-for="item in modelList" :key="item.id" 
                            @click="selModel(item)">
                            <div :class="['m-list-item',curModelId == item.id ? 'm-selected':'']">
                                <img v-if="curModelId == item.id ? true : false" 
                                    class="m-list-item-radio"  src="../images/write/xuanzhong.png" alt="">
                                <img class="model-logo" :src="item.img" />
                            </div>
                            <div class="model-name">
                                <span>{{ item.templateName }}</span>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 下一步工作安排 -->
                <div class="content-need">
                    <div class="field-label">
                        <span class="tit_text">内容要求</span>
                    </div>
                    <div class="area-title">
                        <textarea id="voiceContentNeed" :readonly="2==voiceType" @focus="handleInputFocus" @blur="handleInputBlur" cols="2" class="area-input" placeholder="示例：三级大纲，内容要包含智慧办公产品介绍，写作风格要偏专业" v-model="form.contentNeed"></textarea>
                        <div class="img-div area-voice active-brightness" v-if="2!=voiceType" @click="startTalk(2)">
                            <img class="area-voice" src="../images/write/voice-play.png"/>
                        </div>
                        <div class="img-div area-voice active-brightness" v-if="2==voiceType" @click="stopTalk(2)">
                            <img class="area-voice" src="../images/write/stop.png"/>
                        </div>
                    </div>
                </div>
                <!-- 参考素材 -->
                <div class="material-need">
                    <div class="field-label">
                        <span class="tit_text">参考文件<span class="first_span_img">*</span></span><span class="max-tip">（最多上传5份文档）</span>
                    </div>
                    <div class="material">
                        <div :class="materialList.length == 0 ? 'hasnt-file' : 'has-file'" ref="meterialRef">
                            <div v-for="item in materialList" :key="item.id" class="item">
                                <div class="row">
                                    <div @click="preview(item)" class="imgDiv"><img class="img"
                                            :src="'../images/'+item.type+'.png'" />
                                    </div>
                                    <div>
                                        <div class="tip-close active-brightness" @click="delMaterialFile(item)">
                                            <img class="tip-close-img" src="../images/close.png" alt="" />
                                        </div>
                                        <div class="title file-title">{{ item.fileName }}</div>
                                        <div class="desc">{{ item.type }}<span
                                                style="margin: 0 0.1rem 0 0.1rem;"></span>{{item.fileSize}}</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div @click="chooseUpload(0)" v-if="materialList.length > 0 && materialList.length < 10" class="has-file-upload active-brightness">
                            <img src="../images/write/has-file-upload.png" />
                        </div>
                        <div class="img-div active-brightness" @click="chooseUpload(0)" v-if="materialList.length == 0">
                            <div class="upload-prompt">
                                <img class="upload-prompt-image" src="../images/write/upload1.png" />
                                <span class="prompt-text">点击此处上传文件</span>
                                <span class="prompt-text2">支持上传word文件、文件大小不超过20M</span>
                            </div>
                            <!-- <img class="empty-file" src="../images/write/upload.png" /> -->
                        </div>
                    </div>
                </div>
                <!-- 生辰大纲按钮 -->
                <div class="bottom">
                    <van-button v-if="bottomShow" class="submit-btn" @click="nextStep()">生成内容</van-button>
                </div>
            </div>
            <!-- 生成内容 -->
            <div v-if="currentStep == 2" class="step2">
                <div id="step2Main" :class="['step2-main', improveFile.id ? 'add-file':'no-file']">
                    <div ref="contentRef" class="step2-f" v-if="programHtmlContent">
                        <!-- <van-popover
                        v-model="showPopover"
                        overlayClassName="my-popover"
                        :actions="actions"
                        placement="top"
                        @closed="closePopOver()"
                        theme="dark"
                        >
                        <div id="edit-popover" >
                            <div clickable @click="handleEditPContent">编辑</div>
                            <div class="edit-arrow"></div>
                        </div> -->
                        <div id="myPopover" class="my-popover active-brightness" @click="handleEditPContent">
                            <div><span>编辑</span></div>
                            <div class="edit-arrow"></div>
                        </div>
                        <!-- <template #reference> -->
                            <div id="step3-mdBody" class="step2-content markdown-body" v-html="programHtmlContent">
                            </div>
                        <!-- </template>
                        </van-popover> -->
                        
                    </div>
                </div>
                <div class="step2-bottom">
                    <div class="upload-file-div" v-if="improveFile.id">
                        <div class="file-close active-brightness" @click="delImproveFile">
                            <img src="../images/close.png" alt="" />
                        </div>
                        <div class="tip-f active-brightness" @click="preview(improveFile)">
                            <div class="chat-f-l">
                                <img v-if="'word'==improveFile.type" src="../images/word.png" alt="" />
                                <img v-if="'IMG'==improveFile.type" src="../images/img.png" alt="" />
                            </div>
                            <div class="chat-f-r">
                                <div class="chat-f-r1">{{ improveFile.fileName }}</div>
                                <div class="chat-f-r2">
                                    <span class="chat-f-r2-f">
                                        {{ improveFile.type }}
                                    </span>
                                    <span class="chat-f-r2-s">
                                        {{ improveFile.fileSize }}
                                    </span>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="quick-btn">
                        <div :class="['spanBackGround active-brightness', quickSel == item.type ? 'quick-sel' : '']"
                            v-for="item in quickList" :key="item.id" @click="selQuickType($event, item)">{{item.title}}
                        </div>
                    </div>
                    <!-- 提问框 -->
                    <div class="search">
                        <div class="img-div active-brightness" v-if="3!=voiceType" @click="handleImproveTalk">
                            <img class="voice-img" src="../images/write/voice.png"/>
                        </div>
                        <div class="img-div active-brightness" v-if="3==voiceType" @click="stopTalk(3)">
                            <img class="voice-img" src="../images/write/stop.png"/>
                        </div>
                        <input id="voiceRequireText" :readonly="3==voiceType" class="search-text" placeholder="请输入要求和上传文件" v-model="requireText" />
                        <div class="img-div active-brightness" @click="chooseUpload(1)">
                            <img class="upload-img" src="../images/upload.png" />
                        </div>
                        <div class="img-div active-brightness" v-if="quickSel" @click="genImprove">
                            <img class="send-img" src="../images/write/send.png"/>
                        </div>
                        <div class="img-div" v-if="!quickSel" @click="handleNoSend">
                            <img class="send-img" src="../images/write/no-send.png" />
                        </div>
                    </div>
                </div>
            </div>
            <!-- 文档校核 -->
            <div v-if="currentStep == 3" class="step3">
                <div class="step3-main">
                    <div v-if="'' != checkHtmlContent" class="step3-f" ref="checkRef">
                        <div class="step3-content markdown-body" id="checkDiv" v-html="checkHtmlContent"></div>
                    </div>
                    <!-- <div class="step3-f-2">
                        <van-button type="default" class="step3-btn-l" @click="neglectAll()">一键忽略</van-button>
                        <van-button class="step3-btn-r" @click="modifyAll()">一键更正</van-button>
                    </div> -->
                </div>
                <div class="step3-bottom">
                    <div class="step3-quick-btn">
                        <van-badge class="step3-badge" color="#F20E0E" :content="item.count <= 9 ? (0==item.count?'':item.count) : '9+'" v-for="item in errorList" :key="item.id">
                            <div :class="['step3-spanBackGround active-brightness', errorSel == item.type ? 'quick-sel' : '']"  @click="selErrorType(item)">{{item.title}}</div>
                        </van-badge>
                    </div>
                    <div class="step3-bottom-btn">
                        <van-button :disabled="0==errorCount" type="default" class="step3-btn-l" @click="neglectAll()">一键忽略</van-button>
                        <van-button :disabled="0==errorCount" class="step3-btn-r" @click="modifyAll()">一键更正</van-button>
                    </div>
                </div>
            </div>
            <!-- 生成总结 -->
            <div v-if="currentStep == 4">
                <div class="program-result">
                    <div class="program">
                        <div class="program-item active-brightness" v-if="wordResult.id" @click="preview(wordResult)">
                            <div class="program-item-left">
                                <img :src="'../images/word.png'" />
                            </div>
                            <div class="program-item-right">
                                <div class="right-title">{{ wordResult.fileName }}</div>
                                <div class="right-desc">WORD<span
                                        style="margin: 0 0.1rem 0 0.1rem;"></span>{{wordResult.fileSize}}</div>
                            </div>
                        </div>
                        <div class="program-item" v-else>
                            <div class="program-item-left">
                                <img :src="'../images/word.png'" />
                            </div>
                            <div class="program-item-right2">
                                <img src="../../../image/loading2.gif" />
                                <div class="loading-tip">文件正在生成中</div>
                            </div>
                        </div>
                        <van-divider
                            :style="{ color: '#999', borderColor: '#999', padding: '0 16px' }"></van-divider>
                        <div class="program-btn">
                            <div v-if="wordResult.id" class="img-div-l img-div active-brightness" @click="showPptSheet(wordResult)">
                                <img :src="pptLoading ? '../images/write/ppt-gray.png' : '../images/write/ppt-light.png'"
                                     />
                            </div>
                            <div class="img-div">
                                <div v-if="wordResult.id" class="img-div active-brightness" @click="sendMyEmail(wordResult)">
                                    <img src="../images/write/send-mail.png" />
                                </div>
                                <div v-if="wordResult.id" class="img-div active-brightness" @click="syncToInner(wordResult)">
                                    <img src="../images/write/sync.png" />
                                </div>
                                <div v-if="wordResult.id" class="img-div active-brightness" @click="shareIgw(wordResult)">
                                    <img src="../images/write/share.png" />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="program" v-if="pptLoading">
                        <div class="program-item active-brightness" v-if="wordResult.id && pptResult.id" @click="preview(pptResult)">
                            <div class="program-item-left">
                                <img :src="'../images/ppt.png'" />
                            </div>
                            <div class="program-item-right">
                                <div class="right-title">{{ pptResult.fileName }}</div>
                                <div class="right-desc">PPT<span
                                        style="margin: 0 0.1rem 0 0.1rem;"></span>{{pptResult.fileSize}}</div>
                            </div>
                        </div>
                        <div class="program-item" v-if="wordResult.id && !pptResult.id">
                            <div class="program-item-left">
                                <img :src="'../images/ppt.png'" />
                            </div>
                            <div class="program-item-right2">
                                <img src="../../../image/loading2.gif" />
                                <div class="loading-tip">文件正在生成中</div>
                            </div>
                        </div>
                        <van-divider
                            :style="{ color: '#999', borderColor: '#999', padding: '0 16px' }"></van-divider>
                        <div class="program-btn">
                            <div class="img-div-l"></div>
                            <div class="img-div">
                                <div v-if="pptResult.id" class="img-div active-brightness" @click="sendMyEmail(pptResult)">
                                    <img src="../images/write/send-mail.png" />
                                </div>
                                <div v-if="pptResult.id" class="img-div active-brightness" @click="syncToInner(pptResult)">
                                    <img src="../images/write/sync.png" />
                                </div>
                                <div v-if="pptResult.id" class="img-div active-brightness" @click="shareIgw(pptResult)">
                                    <img src="../images/write/share.png" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 编辑大纲 -->
            <van-action-sheet class="p-edit-sheet" v-model:show="canEditContent" title="编辑大纲" closeable>
                <div class="p-edit-item">
                    <div class="p-edit-cont markdown-body" id="mdBody" contenteditable="true" v-html="editPContent">
                        <!-- {{editPContent}} -->
                    </div>
                    
                    <div class="p-edit-foot">
                        <van-button type="default" class="p-edit-btn-cancle" @click="cancleEdit()">取消</van-button>
                        <van-button class="p-edit-btn-confirm" @click="confirmEdit()">确定</van-button>
                    </div>
                </div>
                
            </van-action-sheet>
            <!-- 续写扩写润色 -->
            <van-action-sheet class="p-edit-sheet" v-model:show="showExConPo" :title="writeTitle" closeable>
                <div class="extend-edit-item">
                    <div class="extend-edit-cont markdown-body" ref="improveRef">
                        <div id="improveDiv" v-html="replaceHtmlContent"></div>
                    </div>
                    
                </div>
                <div class="extend-edit-foot">
                    <van-button type="default" class="p-edit-btn-cancle stop-btn" @click="stopGen()" v-if="generating" icon ="../images/write/stop.png"/>停止生成</van-button>
                    <div class="img-div active-brightness" @click="reGen()" v-if="!generating">
                        <img class="extend-rewrite-btn" src="../images/write/rewrite.png" />
                    </div>
                    <van-button class="extend-edit-btn-cancle" @click="contentCancle()" v-if="!generating">取消</van-button>
                    <van-button class="extend-edit-btn-confirm" @click="contentReplace()" v-if="!generating">替换</van-button>
                </div>
            </van-action-sheet>
            <!-- 一键更正或忽略弹窗 -->
            <van-dialog v-model="showMDialog" title="一键更正" message="是否将所有错误批量修改？"  confirm-button-color="#6090BE" show-cancel-button @confirm="mConfirm()" @cancle="mCancle()">
            </van-dialog>
            <van-dialog v-model="showNDialog" title="一键忽略" message="是否将所有错误批量忽略？" confirm-button-color="#6090BE" show-cancel-button @confirm="nConfirm()" @cancle="nCancle()">
            </van-dialog>
            <!-- 错误列表 -->
             <div class="error-dialog">
                <van-dialog v-model="showErrDialog" :show-confirm-button="false" close-on-click-overlay :message-align="left" :overlay="false">
                    <template #title>
                        <div class="">
                          <span class="dialog_title">{{errTitle}}</span>
                          <van-icon class="close active-brightness" @click="closeErrDialog()" name="cross">
                          </van-icon>
                        </div>
                      </template>
                      
                      <template #default>
                        <van-divider style="width:100%;"></van-divider>
                        <div class="dialog_content">
                            <div v-for="item in errContList" :key="item.id" class="err-item">
                                <div class="err-cont">
                                    {{item.cont}}
                                </div>
                                <div class="err-btn active-brightness" @click="toErrorPos(item)">定位</div>
                            </div>
                        </div>
                      </template>
                </van-dialog>
             </div>
            <!-- 定位弹窗 -->
            <van-dialog v-model="showPositionDialog" show-cancel-button 
                confirm-button-text="修改" cancel-button-text="忽略" 
                @confirm="handleEditError" @cancel="handleIgnoreError">
                <template #title>
                    <div class="">
                      <span class="dialog_title">定位弹窗</span>
                      <van-icon class="close active-brightness" @click="closePositionDialog()" name="cross">
                      </van-icon>
                    </div>
                  </template>
                  
                  <template #default>
                    <van-divider style="width:100%;"></van-divider>
                    <div class="dialog_content">
                        “{{updateError.cont}}”建议修改为“{{updateError.rightCont}}”
                    </div>
                  </template>
            </van-dialog>
            <!-- 内容编辑 -->
            <van-action-sheet class="cont-edit-sheet" v-model:show="showEditDialog" title="编辑" closeable>
                <div class="cont-edit-item">
                    <div class="cont-area">
                        <van-field v-model="editGenCont" rows="5" autosize type="textarea">
                            <template v-slot:input>
                                <div class="markdown-body" contenteditable="true" v-html="editGenCont" @input="changeCont($event)"></div>
                            </template>
                        </van-field>
                    </div>
                    <div class="p-edit-foot">
                        <van-button class="p-edit-btn-cancle" @click="editCancle()">取消</van-button>
                        <van-button class="p-edit-btn-confirm" @click="editConfirm()">确定</van-button>
                    </div>
                </div>
            </van-action-sheet>
            <!-- ppt模板选择 -->
            <van-action-sheet  class="ppt-model-sheet" v-model:show="showPptDialog" title="PPT辅助生成" closeable>
                <div class="ppt-subject" >
                    <div class="field-label">
                        <span class="tit_text">文件标题</span><span class="first_span_img">*</span>
                    </div>
                    <div class="subject-title">
                        <input class="subject-input" placeholder="示例：xxxx项目" v-model="pptForm.title" />
                    </div>
                </div>
                <div class="model-area">
                    <div class="field-label" style="margin-top: 0.2rem;">
                        <span class="tit_text">选择模板</span><span class="first_span_img">*</span><span class="max-tip">（向左滑动选择更多模板）</span>
                    </div>
                    <div class="gray_text">专用模板</div>
                    <div class="ppt-item-list m-scroll" @scroll="handleSpecialScroll">
                        <div v-for="(item, index) in specialList" :key="index" 
                            :class="['ppt-item active-brightness',pptForm.modelId == item.id ? 'm-selected':'']" @click="selPptModel(item)">
                            <img v-if="pptForm.modelId == item.id" 
                                class="m-list-item-radio"  src="../images/write/xuanzhong.png" alt="">
                            <img :src="item.coverUrl" :class="['model-img', pptForm.modelId == item.id ? 'ppt-model-selected':'']"/>
                        </div>
                    </div>
                    <div class="gray_text" style="margin-top: 0.2rem;">通用模板</div>
                    <div class="ppt-item-list m-scroll" id="general" @scroll="handleGeneralScroll">
                        <div v-for="(item, index) in generalList" :key="index" 
                            :class="['ppt-item active-brightness',pptForm.modelId == item.id ? 'm-selected':'']" @click="selPptModel(item)">
                            <img v-if="pptForm.modelId == item.id ? true : false" 
                                class="m-list-item-radio"  src="../images/write/xuanzhong.png" alt="">
                            <img :src="item.coverUrl" :class="['model-img', pptForm.modelId == item.id ? 'ppt-model-selected':'']"/>
                        </div>
                    </div>
                </div>
                <div class="ppt-model-bottom">
                    <van-button class="ppt-submit-btn" @click="createPpt()">PPT辅助生成</van-button>
                </div>
            </van-action-sheet>
        </div>
    </div>

    <script src="../js/workReport.js"></script>
</body>

</html>